unit MLPAOptions;

interface

uses Windows, SysUtils, Classes, Graphics, Forms, Controls, StdCtrls,
  Buttons, ExtCtrls, Dialogs, ComCtrls, Mask, Spin;

type

  TRawDataType = (PeakHeight, PeakArea);

const
  rdtNames : array[PeakHeight..PeakArea] of string = ('Peak height','Peak area');
type

  TfrmMLPAOptions = class(TForm)
    OKBtn: TButton;
    CancelBtn: TButton;
    PageControl: TPageControl;
    tsPrintAnalysis: TTabSheet;
    FontDialog: TFontDialog;
    GroupBox1: TGroupBox;
    Label1: TLabel;
    stHeaderFont: TStaticText;
    Label2: TLabel;
    stBodytextFont: TStaticText;
    GroupBox2: TGroupBox;
    Label3: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    Label6: TLabel;
    edtAnalysisMarginTop: TMaskEdit;
    edtAnalysisMarginBottom: TMaskEdit;
    edtAnalysisMarginLeft: TMaskEdit;
    edtAnalysisMarginRight: TMaskEdit;
    tsAnalysisSettings: TTabSheet;
    cbUseControlProbes: TCheckBox;
    cbUseControlSamples: TCheckBox;
    rgRawValueType: TRadioGroup;
    Label8: TLabel;
    seMedPolishRounds: TSpinEdit;
    seStableProbes: TSpinEdit;
    Label7: TLabel;
    tsImport: TTabSheet;
    cbAutoCreateAssays: TCheckBox;
    procedure stHeaderFontClick(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure stBodytextFontClick(Sender: TObject);
  private
    FAnalysisHeaderFont: TFont;
    FAnalysisBodyFont: TFont;
    FAnalysisMarginLeft: Integer;
    FAnalysisMarginTop: Integer;
    FAnalysisMarginBottom: Integer;
    FAnalysisMarginRight: Integer;
    FAnalysisUseControlSamples: boolean;
    FAnalysisUseControlProbes: boolean;
    FAnalysisMedPolish: Integer;
    FAnalysisRawDataType: TRawDataType;
    FAnalysisStableProbes: integer;
    FImportAutoCreateAssays: boolean;
    procedure Copy2Properties;
    procedure Copy2Components;
    procedure SetImportAutoCreateAssays(const Value: boolean);
    { Private declarations }
  public
    { Public declarations }
    procedure ShowOptions;
    property AnalysisHeaderFont : TFont read FAnalysisHeaderFont write FAnalysisHeaderFont;
    property AnalysisBodyFont : TFont read FAnalysisBodyFont write FAnalysisBodyFont;
    property AnalysisMarginTop : Integer read FAnalysisMarginTop write FAnalysisMarginTop;
    property AnalysisMarginBottom : Integer read FAnalysisMarginBottom write FAnalysisMarginBottom;
    property AnalysisMarginLeft : Integer read FAnalysisMarginLeft write FAnalysisMarginLeft;
    property AnalysisMarginRight : Integer read FAnalysisMarginRight write FAnalysisMarginRight;
    property AnalysisMedPolish : Integer read FAnalysisMedPolish write FAnalysisMedPolish;
    property AnalysisStableProbes : integer read FAnalysisStableProbes write FAnalysisStableProbes;
    property AnalysisUseControlProbes : boolean read FAnalysisUseControlProbes write FAnalysisUseControlProbes;
    property AnalysisUseControlSamples : boolean read FAnalysisUseControlSamples write FAnalysisUseControlSamples;
    property AnalysisRawDataType: TRawDataType read FAnalysisRawDataType write FAnalysisRawDataType;
    property ImportAutoCreateAssays: boolean read FImportAutoCreateAssays write SetImportAutoCreateAssays;
  end;

var
  frmMLPAOptions: TfrmMLPAOptions;

implementation
uses MLPAmain;
{$R *.DFM}


procedure TfrmMLPAOptions.SetImportAutoCreateAssays(const Value: boolean);
begin
  FImportAutoCreateAssays := Value;
end;

procedure TfrmMLPAOptions.ShowOptions;
begin
  // fill components with property values
  Copy2Components;
  if ShowModal=mrOK then
  begin
    // fill properties with component values
    Copy2Properties;
  end;
end;

procedure TfrmMLPAOptions.stHeaderFontClick(Sender: TObject);
begin
  FontDialog.Font.Assign(stHeaderFont.Font);
  if FontDialog.Execute then
    stHeaderFont.Font.Assign(FontDialog.Font);
end;

procedure TfrmMLPAOptions.FormCreate(Sender: TObject);
begin
  FAnalysisHeaderFont:=TFont.Create;
  FAnalysisBodyFont:=TFont.Create;
  // fill properties with default values
  Copy2Properties;
end;

procedure TfrmMLPAOptions.Copy2Properties;
begin
  FAnalysisHeaderFont.Assign(stHeaderFont.Font);
  FAnalysisBodyFont.Assign(stBodytextFont.Font);
  FAnalysisMarginTop:=StrToInt(Trim(edtAnalysisMarginTop.Text));
  FAnalysisMarginBottom:=StrToInt(Trim(edtAnalysisMarginBottom.Text));
  FAnalysisMarginLeft:=StrToInt(Trim(edtAnalysisMarginLeft.Text));
  FAnalysisMarginRight:=StrToInt(Trim(edtAnalysisMarginRight.Text));
  FAnalysisUseControlSamples:=cbUseControlSamples.Checked;
  FAnalysisUseControlProbes:=cbUseControlProbes.Checked;
  FAnalysisStableProbes:=seStableProbes.Value;
  FAnalysisMedPolish:=seMedPolishRounds.Value;
  FAnalysisRawDataType:=TRawDataType(rgRawValueType.ItemIndex);
  ImportAutoCreateAssays:=cbAutoCreateAssays.Checked;
end;

procedure TfrmMLPAOptions.stBodytextFontClick(Sender: TObject);
begin
  FontDialog.Font.Assign(stBodytextFont.Font);
  if FontDialog.Execute then
    stBodytextFont.Font.Assign(FontDialog.Font);
end;

procedure TfrmMLPAOptions.Copy2Components;
begin
  stHeaderFont.Font.Assign(FAnalysisHeaderFont);
  stBodytextFont.Font.Assign(FAnalysisBodyFont);
  edtAnalysisMarginTop.Text:=IntToStr(FAnalysisMarginTop);
  edtAnalysisMarginBottom.Text:=IntToStr(FAnalysisMarginBottom);
  edtAnalysisMarginLeft.Text:=IntToStr(FAnalysisMarginLeft);
  edtAnalysisMarginRight.Text:=IntToStr(FAnalysisMarginRight);
  cbUseControlSamples.Checked:=FAnalysisUseControlSamples;
  cbUseControlProbes.Checked:=FAnalysisUseControlProbes;
  seStableProbes.Value:=FAnalysisStableProbes;
  seMedPolishRounds.Value:=FAnalysisMedPolish;
  rgRawValueType.ItemIndex:=Integer(FAnalysisRawDataType);
  cbAutoCreateAssays.Checked:=ImportAutoCreateAssays;
end;

end.
